package com.cssw.fyzb.wap.service;

import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.wap.model.dto.TeamNumDto;
import com.cssw.fyzb.wap.model.vo.PublicUserInfoVo;
import com.cssw.fyzb.wap.model.vo.TeamDateCountVo;
import com.cssw.fyzb.wap.model.vo.TeamNumVo;
import com.ydn.appserver.MinaAppClient;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TeamService extends BaseService {
    private static final Logger logger = LoggerFactory.getLogger(UserService.class);

    @Autowired
    private MinaAppClient busiClient;


    /**
     * 获取团队列表
     *
     * @return
     */
    public AjaxPage listTeam(Long userId, int pageNumber, int pageSize, int type) {
        Request request = new Request("ListTeam");
        request.setParameter("userId", userId);
        request.setParameter("pageNumber", pageNumber);
        request.setParameter("pageSize", pageSize);
        request.setParameter("type", type);

        return convertPage(busiClient.send(request), PublicUserInfoVo.class);
    }

    public AjaxData getTeamNum(Long userId){
        Request request = new Request("GetTeamNum");
        request.setParameter("userId", userId);
        Response response = busiClient.send(request);
        TeamNumDto teamNumDto = new TeamNumDto();
        teamNumDto.setNum(response.getInteger("num"));
        return AjaxData.success(teamNumDto);
    }


    public AjaxPage listTeamByDate(Long userId){
        Request request = new Request("ListTeamByDate");
        request.setParameter("userId", userId);
        return convertPage(busiClient.send(request), TeamDateCountVo.class);
    }
}
